package Service;

import Dao.Impl.AdminDAOImpl;
import Dao.Impl.CarDAOImpl;
import pojo.Car;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CarService {
    private CarDAOImpl carDAOImpl;

    public CarService() throws Exception {
        carDAOImpl = new CarDAOImpl();
    }

    //获取所有车辆信息展示在管理员窗口
    public List<Car> getAllCars() throws Exception {
        List<Car> carList = carDAOImpl.getAllCars();
        return carList;
    }

    //用户在用户界面租车时更新车的信息
    public Boolean updateByCar(Car car) throws Exception {
        car.setStatus("已租");
        return carDAOImpl.updateByCar(car);
    }

    //管理员删除车辆信息
    public void deleteCar(int carId) throws Exception {
        carDAOImpl.deleteCar(carId);
    }

    //由品牌获取车辆信息展示在管理员窗口
    public List<Car> getCarByBrand(String carBrand) throws Exception {
        return carDAOImpl.getAllCarsByBrand(carBrand);
    }

    //管理员添加车辆信息
    public Boolean addCar(Car car) throws Exception {
        return carDAOImpl.addCar(car);
    }

    //管理员取消订单车辆更新状态
    public void updateCarStatus(int carId) throws Exception {
        carDAOImpl.updateCarStatus(carId);
    }

    public void updateCarById(int data_id, Car car) throws Exception {
        carDAOImpl.updateCarById(data_id,car);
    }
}
